#include <bits/stdc++.h>

using std::swap;
using std::sort;

const int maxn=50005;
const int offset=100005;
const int inf=0x3f3f3f3f;

struct iostream{
	FILE *i,*o;
	const static int bufsiz=1500000;
	char inbuf[bufsiz],oubuf[bufsiz];
	int inp,oup;

	iostream(FILE *i=stdin,FILE *o=stdout):i(i),o(o),oup(0){}
	inline iostream& operator >> (char &c){
		static int end=bufsiz;
		if(inp==end) end=fread(inbuf,1,bufsiz,i),inp=0;
		if(inp==end) c=EOF;
		else c=inbuf[inp++];
		return *this;
	}
	template <typename T> inline iostream& operator >> (T &r){
		char c;bool f=0;
		for(*this>>c;c>'9'||c<'0';*this>>c) if(c=='-') f=1;
		for(r=0;c<='9'&&c>='0';*this>>c) r=r*10+c-'0';
		if(f) r=-r;
		return *this;
	}
	inline iostream& operator << (const char &c){
		oubuf[oup++]=c;
		if(oup==bufsiz) fwrite(oubuf,bufsiz,1,o),oup=0;
		return *this;
	}
	template <typename T> inline iostream& operator << (T r){
		static int sta[50];int head=0;
		if(r<0) *this<<'0',r=-r;
		while(r) sta[head++]=r%10,r/=10;
		if(!head) *this<<'0';
		while(head--) *this<<(char)(sta[head]+'0');
		return *this;
	}
	~iostream(){
		fwrite(oubuf,oup,1,o);
	}
};
struct Query{
	int l,r,id;
	const bool operator < (const Query &q) const {return l==q.l?r>q.r:l>q.l;}
};
struct Edge{
	int u,v,w;
	Edge(const int &u=0,const int &v=0,const int &w=0):u(u),v(v),w(w){}
	const bool operator < (const Edge &e) const {return w<e.w;}
};
struct Pair{
	int w,p;
	Pair(const int &w=inf,const int &p=-1):w(w),p(p){}
	const bool operator < (const Pair &p) const {return w<p.w;}
};
iostream io;
Query q[maxn];Edge e[maxn*4];
int g[maxn],v[maxn*2],nxt[maxn*2];
int en,gn;long long sigma;int sigma_l,sigma_r;
int cnt[maxn],fa[maxn],c[maxn];
bool vis[maxn];
Pair bit[offset*2];
long long ans_n[maxn],ans_d[maxn]; //ans_numerator ans_denominator

inline void addEdge(const int &x,const int &y){
	v[gn]=y;nxt[gn]=g[x];g[x]=gn++;
	v[gn]=x;nxt[gn]=g[y];g[y]=gn++;
}
int find(const int &x){return x==fa[x]?x:fa[x]=find(fa[x]);}
inline const bool cmpByID(const Query &x,const Query &y){return x.id<y.id;}
template <typename T> inline void update(T &x,const T &y){if(y<x) x=y;}
Pair query(int x){
	Pair ans=bit[x];
	for(;x<offset*2;x+=x&-x) update(ans,bit[x]);
	return ans;
}
void insert(int x,const Pair &p){
	for(;x>0;x-=x&-x) update(bit[x],p);
}
inline void solve(const int &n){
	for(int i=0;i<offset*2;i++) bit[i].w=inf,bit[i].p=-1;
	sort(q,q+n);
	for(int i=0;i<n;i++){
		int sum=q[i].l+q[i].r,sub=q[i].r-q[i].l;
		sub+=offset;
		Pair res=query(sub);
		if(res.p!=-1)
			e[en++]=Edge(q[i].id,res.p,res.w-sum);
		insert(sub,Pair(sum,q[i].id));
	}
}
inline void MMST(const int &n){
	solve(n);
	for(int i=0;i<n;i++) swap(q[i].l,q[i].r);
	solve(n);
	for(int i=0;i<n;i++) q[i].l=-q[i].l;
	solve(n);
	for(int i=0;i<n;i++) swap(q[i].l,q[i].r);
	solve(n);
	for(int i=0;i<n;i++){
		swap(q[i].l,q[i].r);q[i].l=-q[i].l;swap(q[i].l,q[i].r);
	}
}
inline void kruskal(const int &n){
	for(int i=0;i<n;i++) fa[i]=i;
	memset(g,-1,sizeof g);
	
	sort(e,e+en);
	for(int i=0;i<en;i++){
		if(find(e[i].u)!=find(e[i].v)){
			fa[find(e[i].u)]=find(e[i].v);
			addEdge(e[i].u,e[i].v);
		}
	}
}
template <typename T> T gcd(const T &x,const T &y){
	return y?gcd(y,x%y):x;
}
inline long long sqr(const long long &x){return x*x;}
inline void adjust(const int &l,const int &r){
	while(sigma_l<l) sigma+=1-2ll*cnt[c[sigma_l]],cnt[c[sigma_l++]]--;
	while(sigma_l>l) sigma+=1+2ll*cnt[c[--sigma_l]],cnt[c[sigma_l]]++;
	while(sigma_r<r) sigma+=1+2ll*cnt[c[++sigma_r]],cnt[c[sigma_r]]++;
	while(sigma_r>r) sigma+=1-2ll*cnt[c[sigma_r]],cnt[c[sigma_r--]]--;
}
void dfs(int p){
	Query &cur=q[p];
	vis[p]=1;
	adjust(cur.l,cur.r);
	ans_n[cur.id]=sigma-(cur.r-cur.l+1ll);
	ans_d[cur.id]=(cur.r-cur.l+1ll)*(cur.r-cur.l);
	if(!ans_d[cur.id]) ans_d[cur.id]=1;
	long long gc;
	gc=gcd(ans_n[cur.id],ans_d[cur.id]);
	ans_n[cur.id]/=gc;ans_d[cur.id]/=gc;
	for(int j=g[p];~j;j=nxt[j]){
		const int &tar=v[j];
		if(vis[tar]) continue;
		dfs(tar);
		adjust(cur.l,cur.r);
	}
}

int main(){
	int n,m;

	freopen("2038.in","r",stdin);
	freopen("2038.out","w",stdout);

	io>>n>>m;
	for(int i=1;i<=n;i++) io>>c[i];
	for(int i=0;i<m;i++) io>>q[i].l>>q[i].r,q[i].id=i;
	MMST(m);
	kruskal(m);
	sort(q,q+m,cmpByID);
	for(int i=q[0].l;i<=q[0].r;i++)
		cnt[c[i]]++;
	for(int i=0;i<maxn;i++) sigma+=sqr(cnt[i]);
	sigma_l=q[0].l;sigma_r=q[0].r;
	dfs(0);
	for(int i=0;i<m;i++) io<<ans_n[i]<<'/'<<ans_d[i]<<'\n';

	return 0;
}
